<?php

namespace addons\ycmx;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Ycmx extends Addons
{
    //插件ycmx后台管理的菜单
    //先在后台生成和配置好菜单，再导出复制到插件文件中 
    protected $menu = [
        [
            'name' => 'ycmx',
            'title' => '用车明细管理',
            'icon' => 'fa fa-list',
            'sublist' =>
            [
                [
                    'name' => 'ycmx/cz',
                    'title' => '车主',
                    'icon' => 'fa fa-circle-o ',
                    'weigh' => 0,
                    'sublist' =>
                    [
                        [
                            'name' => 'ycmx/cz/import',
                            'title' => '导入',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/index',
                            'title' => '查看',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/recyclebin',
                            'title' => '回收站',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/add',
                            'title' => '添加',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/edit',
                            'title' => '编辑',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/del',
                            'title' => '删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/destroy',
                            'title' => '真实删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/restore',
                            'title' => '还原',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/cz/multi',
                            'title' => '批量更新',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                    ],
                ],
                [
                    'name' => 'ycmx/zcdw',
                    'title' => '租车单位',
                    'icon' => 'fa fa-circle-o ',
                    'weigh' => 0,
                    'sublist' =>
                    [
                        [
                            'name' => 'ycmx/zcdw/import',
                            'title' => '导入',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/index',
                            'title' => '查看',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/recyclebin',
                            'title' => '回收站',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/add',
                            'title' => '添加',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/edit',
                            'title' => '编辑',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/del',
                            'title' => '删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/destroy',
                            'title' => '真实删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/restore',
                            'title' => '还原',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/zcdw/multi',
                            'title' => '批量更新',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                    ],
                ],
                [
                    'name' => 'ycmx/lxr',
                    'title' => '联系人',
                    'icon' => 'fa fa-circle-o ',
                    'weigh' => 0,
                    'sublist' =>
                    [
                        [
                            'name' => 'ycmx/lxr/import',
                            'title' => '导入',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/index',
                            'title' => '查看',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/add',
                            'title' => '添加',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/edit',
                            'title' => '编辑',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/del',
                            'title' => '删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/multi',
                            'title' => '批量更新',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/recyclebin',
                            'title' => '回收站',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/destroy',
                            'title' => '真实删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/lxr/restore',
                            'title' => '还原',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                    ],
                ],
                [
                    'name' => 'ycmx/ycmx',
                    'title' => '用车明细',
                    'icon' => 'fa fa-circle-o ',
                    'weigh' => 0,
                    'sublist' =>
                    [
                        [
                            'name' => 'ycmx/ycmx/import',
                            'title' => '导入',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/index',
                            'title' => '查看',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/recyclebin',
                            'title' => '回收站',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/add',
                            'title' => '添加',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/edit',
                            'title' => '编辑',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/del',
                            'title' => '删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/destroy',
                            'title' => '真实删除',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/restore',
                            'title' => '还原',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                        [
                            'name' => 'ycmx/ycmx/multi',
                            'title' => '批量更新',
                            'icon' => 'fa fa-circle-o',
                            'weigh' => 0,
                        ],
                    ],
                ],

            ],
        ],
    ];
    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        Menu::create($this->menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("ycmx");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("ycmx");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("ycmx");
        return true;
    }

    /**
     * 实现钩子方法
     * @return mixed
     */
    public function testhook($param)
    {
        // 调用钩子时候的参数信息
        print_r($param);
        // 当前插件的配置信息，配置信息存在当前目录的config.php文件中，见下方
        print_r($this->getConfig());
        // 可以返回模板，模板文件默认读取的为插件目录中的文件。模板名不能为空！
        //return $this->fetch('view/info');
    }
}
